package com.lzyjkz.quick_auth.controller;

import com.lzyjkz.quick_components.annotation.ExecutedMethodLog;
import com.lzyjkz.quick_components.entity.Response;
import com.lzyjkz.quick_components.service.TokenService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class UserController {

    private final TokenService tokenService;

    @PostMapping("/getInfo")
    @ExecutedMethodLog(params = true, time = true, result = true)
    public Response<UserDetails> getInfo(HttpServletRequest request) {
        return Response.success(tokenService.getUserDetailsByHeader(request));
    }

}
